﻿using System.Windows;
using SilverChart.Core.Configuration;
using SilverChart.Core.Service;

namespace SilverChart.Configuration.Converter {
    [ServiceProvider(LayzeCreation = true, ServiceName = "Default HorizontalAlignment configuration converter", Singleton = true)]
    public class HorizontalAlignmentConverter : ConfigurationConverter<HorizontalAlignment> {

        public bool Convert(string input, out HorizontalAlignment value) {
            switch (input.ToLower()) {
                case "left":
                case "l":
                    value = HorizontalAlignment.Left;
                    break;
                case "center":
                case "c":
                    value = HorizontalAlignment.Center;
                    break;
                case "right":
                case "r":
                    value = HorizontalAlignment.Right;
                    break;
                case "stretch":
                case "s":
                    value = HorizontalAlignment.Stretch;
                    break;
                default:
                    value = HorizontalAlignment.Right;
                    return false;
            }
            return true;
        }
    }
}
